import {
  RouteConfig,
} from '@/types/router';
import { DELETE, GET, POST, PUT } from '../index';
const baseUrl = process.env.APP_NOAH_GRAPH_URL

// 获取树
export const metricTree = (data: any = {}) => {
  return GET<any, RouteConfig>(`${baseUrl}/ai/metric-query/metricTree`, data);
};
// 获取数据源下的查询sql列表
export const getList = (data: any = {}) => {
  return GET<any, RouteConfig>(`${baseUrl}/ai/metric-query/getList`, data);
};
// 获取数据源下的表
export const getTablesByDatasourceId = (data: any = {}) => {
  return GET<any, RouteConfig>(`${baseUrl}/ai/metric-query/getTablesByDatasourceId`, data);
};
// 获取表字段
export const getColumnsByTableId = (data: any = {}) => {
  return GET<any, RouteConfig>(`${baseUrl}/ai/metric-query/getColumnsByTableId`, data);
};
// 获取sql字段
export const sqlMetaData = (data: any = {}) => {
  return POST<any, RouteConfig>(`${baseUrl}/settings/connect/sqlMetaData`, data);
};

// 业务域
export const allDomain = (data: any = {}) => {
  return GET<any, RouteConfig>(`${baseUrl}/settings/business-domain/allDomain`, data);
};
// 创建指标模型
export const modelCreate = (data: any = {}) => {
  return POST<any, RouteConfig>(`${baseUrl}/ds/metric-model-info/create`, data);
};

// 更新指标模型
export const modelUpdate = (data: any = {}) => {
  return PUT<any, RouteConfig>(`${baseUrl}/ds/metric-model-info/update`, data);
};
// 获得指标模型
export const modelGet = (data: any = {}) => {
  return GET<any, RouteConfig>(`${baseUrl}/ds/metric-model-info/get`, data);
};
// 修改指标模型上下线状态
export const updateStatus = (data: any = {}) => {
  return PUT<any, RouteConfig>(`${baseUrl}/ds/metric-model-info/updateStatus?id=${data.id}&status=${data.status}`,);
};
// 删除指标模型
export const modelDelete = (data: any = {}) => {
  return DELETE<any, RouteConfig>(`${baseUrl}/ds/metric-model-info/delete?id=${data.id}`,);
};
// 解析指标模型注释
export const modelAnalysisComment = (data: any = {}) => {
  return POST<any, RouteConfig>(`${baseUrl}/ds/metric-model-info/analysisComment`, data);
};

//根据数据源 查 模型指标数据
export const getModelByDs = (data: any = {} ) => {
  return POST<any, RouteConfig>(`${baseUrl}/ds/metric-model-info/listByNoahx?noahxDatasourceId=${data.dbId}`);
};


/*********************** 指标模型查询  更多分析 使用  *************************************************************************/
// 同/环比 分析
export const compareAnalysis = (data: any = {}) => {
  return POST<any, RouteConfig>(`${baseUrl}/ai/metric-query/compareAnalysis`, data);
};
// 归因分析
export const attributeAnalysis = (data: any = {}) => {
  return POST<any, RouteConfig>(`${baseUrl}/ai/metric-query/attributeAnalysis`, data);
};
// 预测分析
export const predictAnalysis = (data: any = {}) => {
  return POST<any, RouteConfig>(`${baseUrl}/ai/metric-query/predictAnalysis`, data);
};